﻿namespace Utility.Persistence_Service_Test.Entities
{
    public class Bankkonto
    {
        public virtual int Id { get; protected set; }

        public virtual string IBAN { get; set; }

        public virtual Besucher Besucher { get; set; }

        public virtual void SetBesucher(Besucher besucher)
        {
            besucher.Bankkonto = this;
            this.Besucher = besucher;
        }

        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return false;
            }

            if (GetType() != obj.GetType())
            {
                return false;
            }

            Bankkonto konto = (Bankkonto)obj;

            return (Id.Equals(konto.Id)) && (IBAN.Equals(konto.IBAN)) && (Besucher.Equals(konto.Besucher));
        }

        public override int GetHashCode()
        {
            int prime = 31;
            int result = 1;
            result = prime * result + Id.GetHashCode();
            result = prime * result + IBAN.GetHashCode();
            result = prime * result + Besucher.GetHashCode();
            return result;
        }

        public override string ToString()
        {
            return "Bankkonto: {Id: " + this.Id.ToString() + ", IBAN: " + this.IBAN.ToString() + "}";
        }
    }
}
